// Copyright 2022 a.o.smith ALL Rights Reserved
package com.liuxinlong.modules.dao.impl;

import com.liuxinlong.modules.dao.PatentDepartmentSpecialDao;
import com.liuxinlong.modules.entity.PatentDepartmentSpecial;
import com.liuxinlong.modules.mapper.PatentDepartmentSpecialMapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 类描述
 * <p>
 * 此类关联设计的功能
 *
 * @author liuxinlong@hotwater.com.cn
 * @version 1.0.0
 * @since 2023年9月1日
 */
@Service
public class PatentDepartmentSpecialDaoImpl extends ServiceImpl<PatentDepartmentSpecialMapper, PatentDepartmentSpecial> implements PatentDepartmentSpecialDao {

	@Override
	public List<PatentDepartmentSpecial> pageDepartmentSpecialList(Map<String, Object> queryParam) {
		return baseMapper.pageDepartmentSpecialList(queryParam);
	}

	@Override
	public int getDepartmentSpecialCount(Map<String, Object> queryParam) {
		return baseMapper.getDepartmentSpecialCount(queryParam);
	}

	@Override
	public PatentDepartmentSpecial getDepartmentSpecialById(String userId) {
		return baseMapper.getDepartmentSpecialById(userId);
	}

	@Override
	public Map<String, PatentDepartmentSpecial> getDepartmentBranchMap() {
		Map<String,Object> queryParam = new HashMap<>();
		queryParam.put("startNum",0);
		queryParam.put("pageSize",10000);
		List<PatentDepartmentSpecial> dataList = baseMapper.pageDepartmentSpecialList(queryParam);
		Map<String,PatentDepartmentSpecial> dataMap = new HashMap<>();
		for (PatentDepartmentSpecial special: dataList) {
			if (StringUtils.isEmpty(special.getBranch())) {
				continue;
			}
			List<String> branchList = Arrays.asList(special.getBranch().split(","));
			for (String branch : branchList) {
				dataMap.put(branch,special);
			}
		}
		return dataMap;
	}
}
